package day6;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class GetAvg4 {
    public static void main(String[] args) {
        //五门课求平均分，输入的是负值，停止录入并提示错误
        Scanner in = new Scanner(System.in);
        double sum = 0;
        for (int i = 1; i <= 5; i++) {
            System.out.print("请输入第" + i + "门课的成绩:");
            double s = in.nextDouble();
            if (s < 0) {//负值，退出
                System.out.println("输入错误，停止！");
                break;
            }
            sum = sum + s;//求和
            if (i == 5) {//最后一次
                double avg = sum / 5;
                System.out.println("平均分是：" + avg);//有问题。。。
            }
        }


    }
}
